package com.product.statemachine.common.event;

import com.product.statemachine.common.state.State;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
  * @author: caoxingming
  * @data: 2022/6/9 11:57 上午
  * @description: 通用状态变更事件实体类
  **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StateEvent extends Event {

    /**
     * 事件名称
     */
    private String eventName;

    /**
     * 事件描述
     */
    private String eventDesc;

    /**
     * 事件源状态名称
     */
    private String sourceStateName;

    /**
     * 事件源状态
     */
    private State sourceState;

    /**
     * 事件目标状态名称
     */
    private String targetStateName;

    /**
     * 事件目标状态
     */
    private State targetState;

    /**
     * 事件是否变更状态码
     */
    private boolean changeState;


    public boolean getChangeState() {
        if(sourceState.getStateCode().equals(targetState.getStateCode())) {
            return false;
        }
        return true;
    }


}
